package com.yanqu.road.server.logic.recharge.limit.activity;

import com.yanqu.road.entity.activity.ActivityInfo;
import com.yanqu.road.entity.config.goods.MallInfo;
import com.yanqu.road.entity.enums.eActivityType;
import com.yanqu.road.entity.enums.eMallCategory;
import com.yanqu.road.entity.enums.eSystemId;
import com.yanqu.road.entity.mall.LimitBuyResult;
import com.yanqu.road.server.gameplayer.module.activity.snowgarden.SnowGardenModule;
import com.yanqu.road.server.manger.activity.ActivityMgr;
import com.yanqu.road.server.manger.activity.snowgarden.SnowGardenMgr;
import com.yanqu.road.server.manger.config.SystemOpenMgr;
import com.yanqu.road.server.protocol.GameErrorCode;

public class ServerBuyRmbLimit extends BaseActivityMallLimit{

        public ServerBuyRmbLimit(long userId, MallInfo mallInfo, ActivityInfo activityInfo) {
            super(userId, mallInfo, activityInfo);
        }

        @Override
        protected int activityCheck() {
            // 判断活动期间
            if (!ActivityMgr.activityInTime(activityInfo)) {
                return GameErrorCode.E_ACTIVITY_NO_IN_TIME_CANNOT_BUY;
            }
            if (activityInfo.getType() != eActivityType.SnowGarden.getValue()) {
                return GameErrorCode.E_ACTIVITY_NO_IN_TIME_CANNOT_BUY;
            }
            int period = SnowGardenMgr.calcNowPeriod();
            if(mallInfo.getCategory() == eMallCategory.ServerAllBuyMall.getValue()){
                if(period != 1){
                    return GameErrorCode.E_ACTIVITY_NO_IN_TIME_CANNOT_BUY;
                }
            }else if(mallInfo.getCategory() == eMallCategory.ServerAllSecondBuyMall.getValue()){
                if(period != 2){
                    return GameErrorCode.E_ACTIVITY_NO_IN_TIME_CANNOT_BUY;
                }
            }
            return 0;
        }

        @Override
        protected boolean isSystemUnLock() {
            return SystemOpenMgr.systemOpen(player, eSystemId.SnowGarden.getValue());
        }

        @Override
        protected LimitBuyResult buyCountLimit() {
            return activityMallCountLimit(player);
        }

        @Override
        protected int logicCheck() {
            return 0;
        }

}
